home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- CTable.h
-
- Interface for Table class
-
- SUPERCLASS = CPanorama
-
- Copyright © 1991 Symantec Corporation. All rights reserved.
-
-
- ******************************************************************************/
-
- #define _H_CTable /* include file only once */
-
- #include "CPanorama.h" /* include superclass interface */
-
- #ifndef __LISTS__ /* avoid redeclaration of Cell type, defined in "ListMgr.h" */
- typedef Point Cell;
- #endif
-
- typedef enum tTblDrawOrder /* CTable can draw in row major or column major order */
- {
- tblRow,
- tblCol
- } tTblDrawOrder;
-
- typedef struct tTableBorder
- {
- short thickness;
- short penMode;
- Pattern pat;
-
- } tTableBorder;
-
- /* selection flags */
-
- #define selOnlyOne 1L /* only one cell can be selected at a time */
- #define selNoDisjoint 2L /* no disjoint selections allowed */
- #define selExtendDrag 4L /* extend selections by selecting hit cells */
- /* not by extending rectangles */
- #define selDragRects 8L /* dragging always selects rectangles */
-
- class CScrollPane;
- class CRunArray;
- class CMouseTask;
-
- class CTable : public CPanorama
- {
- public:
-
- void ITable(CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight,
- short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing);
-
- virtual void IViewTemp(CView *anEnclosure, CBureaucrat *aSupervisor,
- Ptr viewData);
-
- virtual void SetDefaults( short colWidth, short rowHeight);
- virtual void SetDrawOrder( tTblDrawOrder aDrawOrder);
- virtual void SetScrollPane( CScrollPane *aScrollPane);
-
- /* change size */
-
- virtual void AddRow( short numRows, short afterRow);
- virtual void AddCol( short numCols, short afterCols);
-
- virtual void DeleteRow( short numRows, short startRow);
- virtual void DeleteCol( short numCols, short startCol);
-
- virtual void SetRowHeight( short rowNum, short newHeight);
- virtual void SetColWidth( short colNum, short newWidth);
-
- /* query */
-
- virtual void GetTableBounds( Rect *aTableBounds);
- virtual short GetRowCount( void);
- virtual short GetColCount( void);
- virtual short GetRowHeight( short rowNum);
- virtual short GetColWidth( short colNum);
- virtual long GetRowStart( short rowNum);
- virtual long GetColStart( short colNum);
-
- virtual RgnHandle GetSelection( void);
- virtual long GetSelectionFlags( void);
-
- virtual void GetCellRect( Cell theCell, LongRect *cellRect);
- virtual Boolean IsSelected( Cell aCell);
- virtual Boolean NextCell( Boolean hNext, Boolean vNext, Cell *theCell);
- virtual Boolean GetSelect( Boolean next, Cell *theCell);
-
- virtual short FindRow( long vLoc);
- virtual short FindCol( long hLoc);
- virtual Boolean PixelsToCells( LongRect *pixelsRect, Rect *cellsRect);
- virtual Boolean CellsToPixels( Rect *cellsRect, LongRect *pixelsRect);
-
- /* clicks */
-
- virtual void DoClick( Point hitPt, short modifierKeys, long when);
- virtual void DoDblClick( Cell hitCell, short modifierKeys, long when);
-
- virtual Boolean HitSamePart(Point pointA, Point pointB);
- virtual void FindHitCell( LongPt *hitPt, Cell *hitCell);
-
- virtual void SetDblClickCmd( long aCmd);
-
- virtual void Draw( Rect *area);
-
- virtual void RefreshCell( Cell aCell);
- virtual void RefreshCellRect( Rect *cells);
-
- virtual void SetDrawActiveBorder( Boolean fDrawActiveBorder);
- virtual void SetRowBorders( short thickness, short penMode, Pattern penPat);
- virtual void SetColBorders( short thickness, short penMode, Pattern penPat);
-
- virtual void Paginate( CPrinter *aPrinter, short pageWidth, short pageHeight);
-
- virtual void Activate( void);
- virtual void Deactivate( void);
-
- /* typing */
-
- virtual void DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent);
- virtual void DoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent);
-
- /* commands */
-
- virtual void DoCommand( long aCmd);
- virtual void UpdateMenus( void);
-
- virtual Boolean BecomeGopher( Boolean fBecoming);
-
- /* selecting */
-
- virtual void SetSelectionFlags( long selFlags);
- virtual void SelectCell( Cell aCell, Boolean keepPrevious, Boolean reDraw);
- virtual void SelectRect( Rect *selectRect, Boolean keepPrevious, Boolean reDraw);
- virtual void DeselectCell( Cell aCell, Boolean redraw);
- virtual void DeselectRect( Rect *deselectRect, Boolean redraw);
- virtual void DeselectAll( Boolean redraw);
-
- virtual void ScrollToSelection( void);
-
- /* disposal */
-
- virtual void Dispose( void);
-
- protected:
-
- Rect tableBounds; /* defines table size in cells */
- Point topLeftIndent; /* top and left indent of entire table */
- RgnHandle itsSelection; /* maintains the selection */
-
- CRunArray *itsRows; /* runs of row heights */
- CRunArray *itsCols; /* runs of column widths */
-
- tTblDrawOrder drawOrder; /* defines CTable draws in row or column order */
- short defRowHeight, defColWidth; /* default size of new rows and cols */
- long selectionFlags; /* flags for selection behavior */
-
- FontInfo fontInfo; /* for text tables */
- Point indent; /* used by subclasses for cell drawing */
-
- long dblClickCmd; /* command sent for cell double click */
- Boolean drawActiveBorder;
- Boolean clipToCells;
- Rect qdClip;
-
- tTableBorder rowBorders;
- tTableBorder colBorders;
-
- static RgnHandle cDeselection, cNewSelection, cCurrHilite;
-
-
- void ITableX( void);
- virtual void CreateTextEnvironment( void);
-
- virtual void AdjustBounds( void);
-
- virtual CMouseTask *MakeMouseTask( short modifiers);
- virtual void ClickOutsideBounds( Point hitPt, short modifierKeys, long when);
-
-
- /* drawing */
-
- virtual void DrawRow( short rowNum, short firstCol,
- short lastCol, Boolean doHilite);
- virtual void DrawCol( short colNum, short firstRow,
- short lastRow, Boolean doHilite);
- virtual void DrawCell( Cell theCell, Rect *cellRect);
-
- virtual void DrawBorders( Rect *theCells);
- virtual void Hilite( Rect *cells, Boolean hiliteFlag);
- virtual void HiliteCellRegion( RgnHandle cellRgn, Boolean fHilite);
-
- /* text tables only */
-
- virtual void GetCellText( Cell aCell, short availableWidth, StringPtr itsText);
- };
-
- enum // synonyms for some Boolean parameters
- {
- kDontKeepPrevious = FALSE,
- kKeepPrevious,
- kCurrentOnly = FALSE,
- kCurrentOrNext
- };
- /* utility macro to set a cell */
-
- #define SetCell( aCell, h1, v1) \
- aCell.h = h1, aCell.v = v1
-
-
- /* Change protocol for CTable */
-
- enum
- {
- tableSelectionChanged = bureaucratLastChange + 1, /* info parameter is NULL */
-
- tableLastChange = tableSelectionChanged
-
- };
-
- typedef struct
- {
- PanoramaTemp panorama; /* TCL 1.1.1 DLP 9/18/91 */
- short numRows;
- short rowHeight;
- short numCols;
- short colWidth;
- long selectionFlags;
- long dblClickCmd;
- short drawActiveBorder;
- short rowBorderThickness;
- short rowBorderPenMode;
- short rowBorderPatID;
- short colBorderThickness;
- short colBorderPenMode;
- short colBorderPatID;
-
- } tTableTemp, *tTableTempP;